package com.wn.dead;

import com.wn.User;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import javax.xml.ws.BindingType;

/**
 * @author yellow Docter
 * @date 2023 -07-26
 * @desc   死信队列 进行 消息消费
 */
@Component
public class DeadConsumer {

    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(name = "dead-queue"),
                    exchange = @Exchange(
                            name = "exchange-dlx",
                            type = ExchangeTypes.DIRECT
                    ),
                    key = "dlx"
            )
    )
    public void handlerMsg(@Payload User user){
        System.out.println(" 死信消费者进行消费 = " + user );
    }

}
